New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[@inline] annotation behaves incorrectly on 4.08 (flambda only) #8563
Comments
cc @mshinwell |
This is caused by the
vs
Thus making the function local under flambda, but non-local under
However, there is probably a reason why the optimization was |
After re-reading #2143, it occurs to me that it might be an intended change.
|
The discussion on #2143 suggested that "local" and "inline" should be considered as independent. So, yes, I'd say the current behavior is fine, and if one wants to disable both the inlining and the "local" optimization, one should use both attributes. That said, if someone wants to propose that |
I looked at #2169 to refresh my memory about what functions this transformation applied to, and didn't really find out the answer. I think it might be beneficial to improve the documentation. I think the current behaviour is unfortunate given a fair amount of code exists that assumes "inline never" disallows substitution of a function body (whether taking into account contextual information or not). I wouldn't be surprised if this is going to cause performance regressions. It also seems overly verbose to have to write two separate attributes to produce a straightforward behaviour. I'm not quite convinced whether making "inline never" disable this optimisation is the right thing to do, although it seems like it might be a way out of this; I think something should be done. @chambart Do you have an opinion on this? @lpw25 is away for some time. |
I would like to propose that :) Obviously I was surprised by the behaviour, but that alone shouldn't justify it. The main use of Now, we could add I wasn't familiar with the definition of inlining used in #2143, my working definition was: "Inlining is the pasting of a function's body at the place of usage" |
I was initially in favor of reusing the |
@alainfrisch I was wondering about adding such an attribute. However I'm not really sure what a sensible migration path would be. |
Some extra points because the discussion was too simple:
|
My gut feeling is that the new Lambda simplification is function inlining: inling of sorts, inlining broadly speaking, but inlining nonetheless. Likewise, I would expect that |
So shouldn't we revisit the decision to have a dedicated attribute, instead of supporting |
So:
That works for me and solves the problem in this PR. |
This is close to the original design in #2143 (with the |
I'm not sure that conflating Here we are instead detecting that one of the function's parameters -- its return continuation -- is always the same and specialising the body of the function to the value of that parameter without duplicating the body. It also allows the body to be specialised to the other parameters if any of them are always equal, but only if the continuation parameter is always equal. In this sense it is a somewhat strange optimisation -- it would probably be cleaner in the long run to allow any of the parameters to be specialised regardless of whether the continuation parameter can be. One thing that is not clear to me from the discussion so far is, where was staticcatch itself inlined? Is this just done by linearize, or is there some other optimisation earlier that inlines them? Arguably, it is this step which should be prevented by To a certain extent, the problem here is that the annotation |
(I had written a message with the exact same suggestion of |
Another relevant issue here: if the code of |
In the short term, I can see three directions:
I'm fine with any of these solutions. |
The first and third of those options are probably fine with me, but I would appreciate if someone could answer my question:
before making a decision (I'll be back from vacation next week and can check myself then if people are happy to wait). A simple version of |
Confirmed. Since this issue seems to have stalled, we (jane street) are in the process of writing that ppx. |
In the example given here, inlining is done at the Lambda level ( |
Considering the latest notes, I've dropped the consider-for-release label and the 4.08 milestone. I'm keeping the issue open for now, as a reminder about the idea of the |
That suggests another thing we could do here: adding an |
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc. |
I think that we are still not in an ideal state for this issue. Two more things that should probably be done:
|
can we reopen this issue? |
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc. |
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc. |
On the flambda-backend repo, I've restricted the |
Closes ocaml#2424 The `[@@Cold]` annotation mentioned in the issue is not part of the compiler, but is implemented in `ppx_cold`. The effect of the patch is that it reorders some functions in the binary. See discussion in ocaml/ocaml#8563. Signed-off-by: Etienne Millon <me@emillon.org>
Closes #2424 The `[@@Cold]` annotation mentioned in the issue is not part of the compiler, but is implemented in `ppx_cold`. The effect of the patch is that it reorders some functions in the binary. See discussion in ocaml/ocaml#8563. Signed-off-by: Etienne Millon <me@emillon.org>
The following program, when compiled with flambda on 4.08 (and trunk), does not respect the
[@inline never]
annotation. Cmm is below.When
raise_stuff
is exported by the signature, the[@inline never]
annotation works.This only happens when the
raise_stuff
functions is used exactly once.with 4.07:
with 4.08:
The text was updated successfully, but these errors were encountered: